﻿// Necroz project team © <2015> <ArchLord2EMU>
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 
// Author:Sagara
// Date:2015-09-24-21:57

using System;
using System.Text;
using ArchLord2Commons.Network;

namespace AL2Game.Network.Frames.Send
{
    class SfCreateCharacter : AALNetFrame
    {
        private byte _fraction, _gender, _classId, _race;
        private string _name;
        private byte[] _characterData;

        public SfCreateCharacter(byte fraction, byte gender, byte classId, byte race, string name, byte[] characterData)
        {
            _fraction = fraction;
            _gender = gender;
            _classId = classId;
            _race = race;
            _name = name;
            _characterData = characterData;
        }

        public override void ProcessWrite()
        {
            PutInt8(_fraction);// not sure
            switch (_fraction)
            {
                case 0:
                    PutArray("04084400");
                    PutInt32(2);
                    PutInt64(0);
                    break;
                case 1:
                    PutArray("040ca800");
                    PutInt32(3);
                    PutInt64(1);
                    break;
                default:
                    throw new Exception("Unknown fraction id received!");
            }

            PutFixedString(_name, Encoding.Unicode, 25);

            switch (_fraction)
            {
                case 0:
                    PutArray("00cc4ac16ef05a");
                    break;

                case 1:
                    PutArray("000b6f598f18b8");
                    break;
            }

            PutArray(_characterData);

            switch (_fraction)
            {
                case 0:
                    PutArray("6a9000a402eb539b686500000000000000000000000000000000006a9f6c047d2eaa00000000000000000000000000000000005e51c7478d54170000000000000000000000000000000000d684293beef88f0000000000000000000000000000000000770f2a9e1ed8c900000000000000000000000000000000001f9dc6ad39d0ac0000000000000000000000000000000000a99758ab87c4e2000000000000000000000000000000000041b98d2ffb929d000000000000000000000000000000000041b4d8f82ea7ca000000000000000000000000000000000046711c06edce500000000000000000000000000000000000e1895fab9c2e1b00000000000000000000000000000000005ad4119d1cf54f0000000000000000000000000000000000b6a4043ca4d94e0000000000000000000000000000000000fa679f648cd7c10000000000000000000000000000000000defc3cf552292b0000000000000000000000000000000000f753f794811e730000000000000000000000000000000000e8ac8b23a9a97e00000000000000000000000000000000003e22c463d6428300000000000000000000000000000000005a0ed2c26324ae0000000000000000000000000000000000f20336b179acbf000000000000000000000000000000000028424b980376d30000000000000000000000000000000000266a54dcd90ddd00000000000000000000000000000000007529df17885141000000000000000000000000000000000083e1c3db3c401e000000000000000000000000000000000042704d7c2ce032000000000000000000000000000000000090753aea3c9c62ffffffff010201db0000000000000000000000000000000000000000000000000000000000000000000028ca0000000000000000000000000000000000000000000000000000000000000000000000000000000000b6526f00000000882fdeabd00700007092df448b1195459a198c42");
                    break;
                case 1:
                    PutArray("f8e100b27c9d2c94777e0000000000000000000000000000000000a44c1468c3b07f0000000000000000000000000000000000a6e9b8ab09f1970000000000000000000000000000000000e51bf319cb12580000000000000000000000000000000000d0b4ad98712c820000000000000000000000000000000000125822cbbef9e600000000000000000000000000000000004e9f5c141157ba0000000000000000000000000000000000a3a62fe3824f0d000000000000000000000000000000000099a567dbca3b7d0000000000000000000000000000000000143e373dcf81db000000000000000000000000000000000052268b4e5183380000000000000000000000000000000000f72d739513b4180000000000000000000000000000000000cc3c978bcb8e7a0000000000000000000000000000000000650ac223b6f8d00000000000000000000000000000000000af5d8b0d1517490000000000000000000000000000000000e5b7a51ff54e210000000000000000000000000000000000b4626015dd88930000000000000000000000000000000000e54580edf8dd8200000000000000000000000000000000007eced139f31dd3000000000000000000000000000000000032dea93f83de7000000000000000000000000000000000002589ca74ddabc40000000000000000000000000000000000ecff3953affaa60000000000000000000000000000000000285f3bfc627ab20000000000000000000000000000000000fe97cff585fc7b00000000000000000000000000000000001fe20c2199bb49000000000000000000000000000000000052fa3480921e80ffffffff01010147000000000000000000000000000000000000000000000000000000000000000000005998000000000000000000000000000000000000000000000000000000000000000000000000000000000023b4c000000000fc2967b2d007000062f9c44592e302460080fb42");
                    break;
            }
        }
    }
}
//reply -                                                             
//c613 00 04084400 02000000 0000000000000000 4d00690073007400650072006b006100720079007a00690000 00cc4ac16ef05a 350003001a040808ef0b3f34d80f 6a9000a402eb539b686500000000000000000000000000000000006a9f6c047d2eaa00000000000000000000000000000000005e51c7478d54170000000000000000000000000000000000d684293beef88f0000000000000000000000000000000000770f2a9e1ed8c900000000000000000000000000000000001f9dc6ad39d0ac0000000000000000000000000000000000a99758ab87c4e2000000000000000000000000000000000041b98d2ffb929d000000000000000000000000000000000041b4d8f82ea7ca000000000000000000000000000000000046711c06edce500000000000000000000000000000000000e1895fab9c2e1b00000000000000000000000000000000005ad4119d1cf54f0000000000000000000000000000000000b6a4043ca4d94e0000000000000000000000000000000000fa679f648cd7c10000000000000000000000000000000000defc3cf552292b0000000000000000000000000000000000f753f794811e730000000000000000000000000000000000e8ac8b23a9a97e00000000000000000000000000000000003e22c463d6428300000000000000000000000000000000005a0ed2c26324ae0000000000000000000000000000000000f20336b179acbf000000000000000000000000000000000028424b980376d30000000000000000000000000000000000266a54dcd90ddd00000000000000000000000000000000007529df17885141000000000000000000000000000000000083e1c3db3c401e000000000000000000000000000000000042704d7c2ce032000000000000000000000000000000000090753aea3c9c62ffffffff010201db0000000000000000000000000000000000000000000000000000000000000000000028ca0000000000000000000000000000000000000000000000000000000000000000000000000000000000b6526f00000000882fdeabd00700007092df448b1195459a198c42 --female

//c613 01 040ca800 03000000 0100000000000000 4d006900730074006500720068006100720076006500720000 000b6f598f18b8 640002004c0434081c0c50390410 f8e100b27c9d2c94777e0000000000000000000000000000000000a44c1468c3b07f0000000000000000000000000000000000a6e9b8ab09f1970000000000000000000000000000000000e51bf319cb12580000000000000000000000000000000000d0b4ad98712c820000000000000000000000000000000000125822cbbef9e600000000000000000000000000000000004e9f5c141157ba0000000000000000000000000000000000a3a62fe3824f0d000000000000000000000000000000000099a567dbca3b7d0000000000000000000000000000000000143e373dcf81db000000000000000000000000000000000052268b4e5183380000000000000000000000000000000000f72d739513b4180000000000000000000000000000000000cc3c978bcb8e7a0000000000000000000000000000000000650ac223b6f8d00000000000000000000000000000000000af5d8b0d1517490000000000000000000000000000000000e5b7a51ff54e210000000000000000000000000000000000b4626015dd88930000000000000000000000000000000000e54580edf8dd8200000000000000000000000000000000007eced139f31dd3000000000000000000000000000000000032dea93f83de7000000000000000000000000000000000002589ca74ddabc40000000000000000000000000000000000ecff3953affaa60000000000000000000000000000000000285f3bfc627ab20000000000000000000000000000000000fe97cff585fc7b00000000000000000000000000000000001fe20c2199bb49000000000000000000000000000000000052fa3480921e80ffffffff01010147000000000000000000000000000000000000000000000000000000000000000000005998000000000000000000000000000000000000000000000000000000000000000000000000000000000023b4c000000000fc2967b2d007000062f9c44592e302460080fb42 --male